const loginUrl1 = "http://47.105.173.95:3001/api/users"
const loginUrl = "http://47.105.173.95:3001/auth/login"
const setUrl = "http://47.105.173.95:3001/auth/set"
const loginFormFieldOption = {
    username: {
        selector: '#username',//选择器
        dataKey: "username",//对应的返回数据中的键
    },
    password: {//字段名称
        selector: '#password',//选择器
        dataKey: "password",//对应的返回数据中的键
    },
    remember:{
        selector: '#remember',//选择器
        dataKey: "remember",//对应的返回数据中的键
    }
}
initForm(loginFormFieldOption);

(function bindLogin(){
    const loginBtn = document.getElementById('login-btn')
    loginBtn.onclick = function(e){
        e.preventDefault()
        const userData = getFormValue(loginFormFieldOption)
        login(userData)
    }
})()

function login(userData){
    // $.post(loginUrl,userData,function(res){
    //     console.log(res)
    // })
    // ajax(loginUrl,{
    //     method:"post",
    //     data:userData,
    //     success:function(res){
    //         console.log(res)
    //         alert('登录成功')
    //     }
    // })
    $.get(setUrl,function(res){
        console.log(res)
    })
};
(function bindBtn(){
    const getBtn = document.getElementById('get-btn')
    const setBtn = document.getElementById('set-btn')
    const getUrl = "http://47.105.173.95:3001/auth/get"
    const setUrl = "http://47.105.173.95:3001/auth/set"
    setBtn.onclick = function(){
        $.get(setUrl,{},function(res){
            console.log(res)
        })
    }
    getBtn.onclick = function(){
        $.get(getUrl,{},function(res){
            console.log(res)
        })
    }

})()

